package com.photovoltaic.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.photovoltaic.auth.entity.RolePermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RolePermissionMapper extends BaseMapper<RolePermission> {
    /**
     * 根据角色ID获取对应的权限ID列表
     *
     * @param roleId 角色ID
     * @return 权限ID列表
     */
    @Select("SELECT permission_id FROM role_permission WHERE role_id = #{roleId}")
    List<Long> getRolePermissions(@Param("roleId") Long roleId);
    
    /**
     * 根据角色ID列表获取所有相关的权限ID列表
     *
     * @param roleIds 角色ID列表
     * @return 权限ID列表
     */
    @Select("<script>SELECT permission_id FROM role_permission WHERE role_id IN " +
            "<foreach item='id' collection='roleIds' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach></script>")
    List<Long> getRolesPermissions(@Param("roleIds") List<Long> roleIds);
} 